<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="edu.columbia.ubms.ejb.BlogBoxSessionBeanRemote" %>
<%@ page import="edu.columbia.ubms.ejb.Item" %>

<%@ include file="sessionCheck.jsp"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Blog Add</title>
<link rel="stylesheet" type="text/css" href="ubms.css" media="screen" />
<script language="javaScript">
function checkBox() {
	if (document.regform.sharecheck.checked) {
		document.regform.blogshare.value = "Y";
	} else {
		document.regform.blogshare.value = "N";
	}
}
</script>
</head>
<body>
<%
	//int intUserId = 1;
	//session.setAttribute("userid", Integer.toString(intUserId));
	int userId = (Integer)session.getAttribute("userid");
	int blogBoxId = Integer.parseInt((String)request.getParameter("blogboxid"));
 
	Item item = new Item();
	try {   
	    Context ctx = new InitialContext();		
		BlogBoxSessionBeanRemote beanRemote = (BlogBoxSessionBeanRemote)ctx.lookup("BlogBoxSessionBean/remote");
		item = beanRemote.blogBoxGet(userId, blogBoxId);
	} catch(Exception e) {
	    out.println("Error:" + e.getMessage());
	}	
%>	
<h3>Blog Add</h3>
<form name="regform" action="blogAdd.jsp" method="post">
	<input type="hidden" name="blogboxid" value="<%= blogBoxId %>"/>
	<table class="tab_add">
		<tr>
			<td width="30%">Blog Box</td>
			<td width="30%"><%= item.getBlogboxName() %></td>
		</tr>
		<tr>
			<td>Title</td><td><input class="input_1" type="text" name="blogname"/></td>
		</tr>
		<tr>
			<td>Content</td><td><input class="input_1" type="text" name="blogcontent"/></td>
		</tr>		
		<tr>
			<td>Tag</td><td><input class="input_1" type="text" name="blogtag"/></td>
		</tr>
		<tr>
			<td>Share</td><td><input class="input_1" type="checkbox" name="sharecheck" onClick="checkBox();" checked/></td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="hidden" name="blogshare" value="Y"/>
				<input type="submit" value="Register"/>	
			</td>
		</tr>
	</table>

</form>
</body>
</html>